#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

vector<int>path;
vector<vector<int> >result;

void backtracking(vector<int>candidates,int target,int sum,int startindex){
	if(sum==target){
		result.push_back(path);
		return;
	}
	if(sum>target) return;
    
	for(int i=startindex;i<candidates.size();i++){
		sum+=candidates[i];
		path.push_back(candidates[i]);
		backtracking(candidates,target,sum,i);
		sum-=candidates[i];
		path.pop_back();
	} 
}

int main()
{
	vector<int>candidates={2,3,6,7};
	int target;
	cin>>target;
	backtracking(candidates,target,0,0);
	for(vector<vector<int> >::iterator it=result.begin();it!=result.end();it++){
		for(vector<int>::iterator iit=(*it).begin();iit!=(*it).end();iit++){
			cout<<(*iit)<<' ';
		}
		cout<<endl;
	}
	return 0;
}
 
